'''
1.使用while和for…in两个循环分别输出四种九九乘法表效果（共计8个）。
'''

#使用for...in循环实现99乘法表-1
print('>'*20,'使用for...in循环实现99乘法表-1','<'*20)
for row in range(1,10):
    for col in range(1,row+1):
        print('{}*{}={:<4}'.format(col, row, row * col), end=' ')
    print('')
print('#'*78) #分隔符
for row in range(9,0,-1):
    for col in range(1,row+1):
        print('{}*{}={:<4}'.format(col, row, row * col), end=' ')
    print('')


#使用for...in循环实现99乘法表-2
print('>'*20,'使用for...in循环实现99乘法表-2','<'*20)
for row in range(1,10):
    for col in range(1,row+1):
        print('{}*{}={:<4}'.format(col, row, row * col), end=' ')
    print('')
print('='*78) #分隔符
for row in range(9,0,-1):
    for col in range(1,row+1):
        print('{}*{}={:<4}'.format(col, row, row * col), end=' ')
    print('')

#使用while循环输出99乘法表-3
print('>'*20,'while循环实现99乘法表(1)','<'*20)
row = 1
while row <= 9:
    col = 1
    while col <= row:
        print('{}*{}={:<4}'.format(col, row, row * col), end=' ')
        col = col + 1
    row = row + 1
    print('')
print('='*78) #分隔符
row = 9
while row > 0:
    col = 1
    while col <= row:
        print('{}*{}={:<4}'.format(col, row, row * col), end=' ')
        col = col + 1
    row = row - 1
    print('')


#使用while循环输出99乘法表-3
print('>'*20,'while循环实现99乘法表(2)','<'*20)
row = 1
while row <= 9:
    col = 1
    while col <= row:
        print('{}*{}={:<4}'.format(col, row, row * col), end=' ')
        col = col + 1
    row = row + 1
    print('')
print('='*78) #分隔符
row = 9
while row > 0:
    col = 1
    while col <= row:
        print('{}*{}={:<4}'.format(col, row, row * col), end=' ')
        col = col + 1
    row = row - 1
    print('')
